package com.frank.twloading.slice;

import com.frank.loadinglibrary.common.FactoryComponent;
import com.frank.loadinglibrary.special.catload.CatLoadingElement;
import com.frank.loadinglibrary.special.element.*;
import ohos.aafwk.content.Intent;
import ohos.agp.colors.RgbColor;
import ohos.agp.components.*;
import ohos.agp.components.element.ShapeElement;
import ohos.bundle.AbilityInfo;


public class SpecialAbilitySlice extends BaseSlice {

    private DependentLayout myLayout = new DependentLayout(this);

    @Override
    public void onStart(Intent intent) {
        super.onStart(intent);

        setDisplayOrientation(AbilityInfo.DisplayOrientation.PORTRAIT);
        DirectionalLayout.LayoutConfig config = new DirectionalLayout.LayoutConfig(ComponentContainer.LayoutConfig.MATCH_PARENT, ComponentContainer.LayoutConfig.MATCH_PARENT);
        myLayout.setLayoutConfig(config);
        ShapeElement element = new ShapeElement();
        element.setRgbColor(new RgbColor(231, 87, 100));
        myLayout.setBackground(element);

        DirectionalLayout.LayoutConfig slackconfig = new DirectionalLayout.LayoutConfig(ComponentContainer.LayoutConfig.MATCH_CONTENT, ComponentContainer.LayoutConfig.MATCH_CONTENT);
        FactoryComponent slackLoadingComponent = new FactoryComponent(this);
        slackLoadingComponent.config(new SlackLoadingElement(slackLoadingComponent));
        slackLoadingComponent.setLayoutConfig(slackconfig);
        slackLoadingComponent.setHeight(500);
        slackLoadingComponent.setWidth(500);
        myLayout.addComponent(slackLoadingComponent);


        DirectionalLayout.LayoutConfig titanicconfig = new DirectionalLayout.LayoutConfig(ComponentContainer.LayoutConfig.MATCH_CONTENT, ComponentContainer.LayoutConfig.MATCH_CONTENT);
        FactoryComponent titanicLoadComponent = new FactoryComponent(this);
        titanicLoadComponent.config(new TitanicLoadingElement(titanicLoadComponent));
        titanicLoadComponent.setLayoutConfig(titanicconfig);
        titanicLoadComponent.setHeight(300);
        titanicLoadComponent.setWidth(1000);
        titanicLoadComponent.setMarginTop(500);
        myLayout.addComponent(titanicLoadComponent);

        DirectionalLayout.LayoutConfig catconfig = new DirectionalLayout.LayoutConfig(ComponentContainer.LayoutConfig.MATCH_CONTENT, ComponentContainer.LayoutConfig.MATCH_CONTENT);
        FactoryComponent catLoadingComponent = new FactoryComponent(this);
        catLoadingComponent.config(new CatLoadingElement(catLoadingComponent));
        catLoadingComponent.setLayoutConfig(catconfig);
        catLoadingComponent.setMarginLeft(500);
        catLoadingComponent.setWidth(500);
        catLoadingComponent.setHeight(500);
        myLayout.addComponent(catLoadingComponent);


        DirectionalLayout.LayoutConfig testconfig = new DirectionalLayout.LayoutConfig(ComponentContainer.LayoutConfig.MATCH_CONTENT, ComponentContainer.LayoutConfig.MATCH_CONTENT);
//        CoolLoadingComponent coolLoadingComponent = new CoolLoadingComponent(this);
        FactoryComponent coolLoadingComponent = new FactoryComponent(this);
        coolLoadingComponent.config(new CoolLoadingElement.CoolLoadingBuilder(coolLoadingComponent).build());
        coolLoadingComponent.setLayoutConfig(testconfig);
        coolLoadingComponent.setMarginTop(800);
        coolLoadingComponent.setWidth(1000);
        coolLoadingComponent.setHeight(500);
        coolLoadingComponent.setMarginLeft(100);
        myLayout.addComponent(coolLoadingComponent);

        DirectionalLayout.LayoutConfig electricFanConfig = new DirectionalLayout.LayoutConfig(ComponentContainer.LayoutConfig.MATCH_CONTENT, ComponentContainer.LayoutConfig.MATCH_CONTENT);
        FactoryComponent electricFan = new FactoryComponent(this);
        electricFan.config(new ElectricFanElement.ElectricFanBuilder(electricFan).build());
        electricFan.setLayoutConfig(electricFanConfig);
        electricFan.setWidth(1000);
        electricFan.setHeight(500);
        electricFan.setMarginTop(1100);
        myLayout.addComponent(electricFan);

        super.setUIContent(myLayout);


    }


}
